﻿Imports NearAop

<AddProxyInterface(GetType(Proxy5), GetType(IMyInterface1))>
<AddProxyInterface(GetType(Proxy6), GetType(IMyInterface2))>
Public Class T08_手动初始化代理字段

    '直接使用字段类型
    <SetProxySource>
    ReadOnly proxy5 As Proxy5 = New Proxy5("接口1")

    '直接使用特性指定的类型
    <SetProxySource(GetType(Proxy6))>
    ReadOnly proxy6 As Object = New Proxy6("接口2")

End Class

Class Proxy5
    Implements IMyInterface1
    Private ReadOnly value As String

    Sub New(value As String)
        Me.value = value
    End Sub

    Public Sub ShowMsg1() Implements IMyInterface1.ShowMsg1
        Console.WriteLine(value)
    End Sub

End Class

Class Proxy6
    Implements IMyInterface2

    Private ReadOnly value As String

    Sub New(value As String)
        Me.value = value
    End Sub

    Public Sub ShowMsg2() Implements IMyInterface2.ShowMsg2
        Console.WriteLine(value)
    End Sub

End Class